package com.xiaoxu.intranetweb.mybatisplusSzappdb.mapper;

import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.CIcCardsInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * IC卡信息表 Mapper 接口
 * </p>
 *
 * @author xiaoxu
 * @since 2022-12-27
 */
@Component
public interface CIcCardsInfoMapper extends BaseMapper<CIcCardsInfo> {
    //查询代理卡
    @Select("SELECT *\n" +
            "FROM c_ic_cards_info\n" +
            "WHERE (CARDINF_MODIFY_REASON = '发卡'or CARDINF_MODIFY_REASON = '解挂')\n" +
            "AND CARDINF_DELETED = 0\n" +
            "AND CARDINF_AGENT = 1\n" +
            "AND DATA_FROM = #{plant}\n" +
            "AND CARDINF_TRUCK_PWD = #{truckNo}\n" +
            "AND CARDINF_CUR_VALID =1\n" +
            "ORDER BY CARDINF_CARDNO ASC")
    List<CIcCardsInfo> selectIcAgentByTruckNo(String plant, String truckNo);

    @Select("SELECT *\n" +
            "FROM c_ic_cards_info\n" +
            "WHERE (CARDINF_MODIFY_REASON = '发卡'or CARDINF_MODIFY_REASON = '解挂')\n" +
            "AND CARDINF_DELETED = 0\n" +
            "AND CARDINF_AGENT = 1\n" +
            "AND DATA_FROM = #{plant}\n" +
            "AND CARDINF_TRUCK_PWD = #{truckNo}\n" +
            "AND CARDINF_CUR_VALID =1\n" +
            "ORDER BY CARDINF_CARDNO ASC")
    List<CIcCardsInfo> selectIcAgentByTruckNoById(String plant, String truckNo);
    @Select( "SELECT COUNT(*)\n" +
            "FROM c_ic_cards_info\n" +
            "WHERE  (CARDINF_MODIFY_REASON = '发卡' or CARDINF_MODIFY_REASON = '解挂')\n" +
            "AND CARDINF_DELETED = 0\n" +
            "AND CARDINF_CUR_VALID =1\n" +
            "AND DATA_FROM =#{plant}\n" +
            "AND CARDINF_CARDNO = #{cardinfCardno}\n")
    int selectCountAgent(String plant, String cardinfCardno);
}
